<div class="container">
  <ol class="breadcrumb">
    <li><%= link_to 'Home', root_path %></li>
    <li class="active">Analytic instances</li>
  </ol>
</div>

<div class="container">
  <h1>
    Listing analytic instances
    <a href="<%= new_analytic_instance_path %>" class="btn btn-success">
      <span class="glyphicon glyphicon-upload"></span> Create new analytic instance</a>
  </h1>


  <% if @analytic_instances.empty? %>
      <p>
      <div class="alert alert-warning">
        Currently no analytic instances are registered with the system.
      </div>
      </p>
  <% else %>
      <div class="media">
        <table class="table table-hover">

          <thead>
          <tr>
            <th>#</th>
            <th>Analytic ID</th>
            <th>Name</th>
            <th>Analytic Type</th>
            <th>Description</th>

            <th colspan="4"></th>
          </tr>
          </thead>

          <tbody>
          <% i = 1 %>
          <% @analytic_instances.each do |analytic_instance| %>
              <tr>
                <td><%= i %></td>
                <td><%= analytic_instance.id %></td>
                <td><%= analytic_instance.name %></td>
                <td><%= analytic_instance.analytic.name %></td>
                <td><%= analytic_instance.description %></td>


                <% if isOrganization? %>

                    <td><%= link_to 'Show', group_user_analytic_instance_path(analytic_instance.group_user_id, analytic_instance), :class => "btn btn-xs btn-default" %></td>
                    <td><%= link_to 'Edit', edit_group_user_analytic_instance_path(analytic_instance.group_user_id, analytic_instance), :class => "btn btn-xs btn-warning" %></td>
                    <td><%= link_to 'Destroy', group_user_analytic_instance_path(analytic_instance.group_user_id, analytic_instance), method: :delete, :class => "btn btn-xs btn-danger", data: {confirm: 'Are you sure?'} %></td>

                <% else %>

<<<<<<< HEAD
                    <% if analytic_instance.status == 0 %>

                        <td><%= link_to 'Start', start_analytic_instance_path(analytic_instance), :class => "btn btn-xs btn-warning" %></td>

                    <%elsif analytic_instance.status == 2 %>

                        <td><%= link_to 'Stop', stop_analytic_instance_path(analytic_instance), :class => "btn btn-xs btn-danger", data: {confirm: 'Are you sure?'} %></td>

                    <%else%>
                        <td><%= link_to 'Pending',"#" ,:class => "btn btn-xs btn-info" %></td>
                    <% end %>

                    <td><%= link_to 'Show', analytic_instance, :class => "btn btn-xs btn-default" %></td>
                    <td><%= link_to 'Edit', edit_analytic_instance_path(analytic_instance), :class => "btn btn-xs btn-warning" %></td>
                    <td><%= link_to 'Destroy', analytic_instance, method: :delete, :class => "btn btn-xs btn-danger", data: {confirm: 'Are you sure?'} %></td>


                <% end %>

              </tr>
              <% i = i + 1 %>
          <% end %>
          </tbody>
        </table>
      </div>
  <% end %>
</div>
